#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=200000, maxm=50000, maxsumm=400000;

class Heap {
public:
  int a[maxn+1];

  bool cmp(int x, int y) {
    return a[x]<=a[y];
  }

  void swap(int x, int y) {
    int t;
    t=a[x], a[x]=a[y], a[y]=t;
  }

  void up(int o) {
    if (o>1 && cmp(o, o/2)) {
      swap(o, o/2);
      up(o/2);
    }
  }

  void down(int o) {
    if (((o*2<a[0] && cmp(o*2, o*2+1)) || o*2==a[0]) && cmp(o*2, o)) {
      swap(o*2, o);
      down(o*2);
    } else if ((o*2<a[0] && cmp(o*2+1, o*2)) && cmp(o*2+1, o)) {
      swap(o*2+1, o);
      down(o*2+1);
    }
  }

  void ins(int v) {
    a[++a[0]] = v;
    up(a[0]);
  }

  int pop() {
    int ret=a[1];
    swap(1, a[0]--);
    down(1);
    return ret;
  }
};

class Graph {
public:
  int n, m, ind[maxn+1], to[maxsumm+1], link[maxsumm+1], in[maxn+1];

  void init(int n) {
    this->n = n;
    m = 0;
    for (int i=1; i<=n; i++) {
      ind[i] = 0;
      in[i] = 0;
    }
  }

  void addSide(int u, int v) {
    in[v]++;
    m++;
    to[m] = v;
    link[m] = ind[u];
    ind[u] = m;
  }

  bool check() {
    static int que[maxn+1], tin[maxn+1];
    int h=0, t=0;
    for (int i=1; i<=n; i++) {
      if (!(tin[i] = in[i])) {
        que[++t] = i;
      }
    }
    for (; h<t; ) {
      int x=que[++h];
      for (int i=ind[x]; i; i=link[i]) {
        tin[to[i]]--;
        if (!tin[to[i]]) {
          que[++t] = to[i];
        }
      }
    }
    return t==n;
  }

  void solve(int ans[]) {
    static Heap que;
    for (int i=1; i<=n; i++) {
      if (!in[i]) {
        que.ins(i);
      }
    }
    int cnt=0;
    for (; que.a[0]; ) {
      int x=que.pop();
      ans[++cnt] = x;
      for (int i=ind[x]; i; i=link[i]) {
        in[to[i]]--;
        if (!in[to[i]]) {
          que.ins(to[i]);
        }
      }
    }
  }
};

void genGraph(Graph &g, int src[], int n, int m) {
  int p=0;
  g.init(n);
  for (int i=1; i<=m; i++) {
    int t=src[++p], last=src[++p];
    for (int j=2; j<=t; j++) {
      g.addSide(last, src[++p]);
      last = src[p];
    }
  }
}

int main() {
  freopen("order.in", "r", stdin);
  freopen("order.out", "w", stdout);

  static int src[maxsumm+1];
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i=1; i<=m; i++) {
    int t;
    scanf("%d", &t);
    src[++src[0]] = t;
    for (int i=1; i<=t; i++) {
      scanf("%d", src+(++src[0]));
    }
  }

  static Graph g;
  int tar=0;
  for (int l=1, r=m, mid; l<=r; ) {
    mid=(l+r)/2;
    genGraph(g, src, n, mid);
    if (g.check()) {
      tar = mid;
      l = mid+1;
    } else {
      r = mid-1;
    }
  }
  
  static int ans[maxn+1];
  genGraph(g, src, n, tar);
  g.solve(ans);
  for (int i=1; i<=n; i++) {
    printf("%d ", ans[i]);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
